package appTool

import (
	"gitee.com/kinwyb/appTools/log"
	influxdb "github.com/vrischmann/go-metrics-influxdb"
	"time"
)

// 开启性能统计
func startInfluxDbMetrics(influxDbURL string,
	influxDbName string, influxDbUser string, influxDbPwd string,
	flushTime time.Duration) {
	if flushTime < 1*time.Second {
		flushTime = 5 * time.Second
	}
	if influxDbURL == "" || influxDbName == "" { //时序数据库地址错误不启动
		log.AppTool.Warning("启动InfluxDbMetrics失败: InfluxDb地址或数据库名称为空")
		return
	}
	startMetrics(flushTime)
	go influxdb.InfluxDB(metricsRegistry, flushTime, influxDbURL,
		influxDbName, "go-metrics", influxDbUser, influxDbPwd, true)
}
